package smedi.ismedi.mobile.bff.controller.inmail;

import com.smedi.ismedi.inmail.api.dto.request.QueryListMessageRecordRequest;
import com.smedi.ismedi.inmail.api.dto.request.QueryPageMessageRecordRequest;
import com.smedi.ismedi.inmail.api.dto.response.MessageRecordResponse;
import com.smedi.ismedi.inmail.api.feign.RemoteMessageFeignApi;
import com.smedi.ismedi.web.starter.common.PaginationData;
import com.smedi.ismedi.web.starter.common.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@Api(tags = "消息接口")
@RequestMapping(value = "/mobilebff/v1/message")
@RestController
@AllArgsConstructor
public class MessageController {
    private final RemoteMessageFeignApi messageFeignApi;

    @ApiOperation(httpMethod = "DELETE", value = "删除消息")
    @DeleteMapping("/deleteMessage")
    ResponseData<Boolean> postDeleteUserMessage(@RequestParam("messageIds") List<Long> ids) {
        return messageFeignApi.postDeleteMessage(ids);
    }

    @ApiOperation(httpMethod = "POST", value = "阅读消息")
    @PostMapping("/readMessage")
    ResponseData<List<MessageRecordResponse>> postReadUserMessage(@RequestParam("messageIds") List<Long> ids) {
        return messageFeignApi.postReadMessage(ids);
    }

    @ApiOperation(httpMethod = "GET", value = "消息列表分页")
    @GetMapping("/queryMessagePage")
    ResponseData<PaginationData<MessageRecordResponse>> getQueryUserMessagePage(@Validated @SpringQueryMap QueryPageMessageRecordRequest queryPageMessageRecordRequest) {
        return messageFeignApi.getQueryPageMessage(queryPageMessageRecordRequest);
    }

    @ApiOperation(httpMethod = "GET", value = "消息列表")
    @GetMapping("/queryListMessage")
    ResponseData<List<MessageRecordResponse>> getQueryUserMessageList(@Validated @SpringQueryMap QueryListMessageRecordRequest queryListMessageRecordRequest) {
        return messageFeignApi.getQueryListMessage(queryListMessageRecordRequest);
    }
}
